package com.sophialex.health.record.common.validate;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;

import com.sophialex.health.system.frame.dialog.DialogManager;

/**
 * 
 * <p>Title:Health</p>
 * <p>ActionResult</p>
 * 
 * Alex May 9, 2011 9:26:00 PM create
 * @author <a href='wanghao924@126.com'>Alex</a>
 * QQ: 873987060;
 * @version 1.0
 */
public class ActionResult {
	public static int TIPTYPE_NONE = 0;
	/**
	 * 提示类型：对话框
	 */
	public static int TIPTYPE_DLG = 1;
	/**
	 * 提示类型：调试
	 */
	public static int TIPTYPE_DEBUG = 1 << 2;


	private String info="";// 验证返回文字信息
	private boolean doAfter=true;//是否继续后续动作
	private int tipType = TIPTYPE_NONE;//提示类型
	
	private boolean success=true;// 验证是否成功
	private Object obj=null;//验证失败对象(表格)
	private String field=null;//验证失败字段(表格)

	public ActionResult() {
		super();
	}

	public ActionResult(boolean doAfter, int tipType,String info) {
		super();
		this.info = info;
		this.tipType = tipType;
		this.doAfter=doAfter;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getInfo() {
		return info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public int getTipType() {
		return tipType;
	}

	public void setTipType(int tipType) {
		this.tipType = tipType;
	}
	
	public Object getObj() {
		return obj;
	}

	public void setObj(Object obj) {
		this.obj = obj;
	}

	public String getField() {
		return field;
	}

	public void setField(String field) {
		this.field = field;
	}

	/**
	 * 提示
	 * @param type
	 */
	public void showTip() {
		if ((tipType & TIPTYPE_DLG) != 0) {
			DialogManager.invokeRCPMessageBox("提示", info, SWT.YES);
		}
		if ((tipType & TIPTYPE_DEBUG) != 0) {
			System.out.println(info);
			// logger 使用log4j
		}
	}

	public boolean isDoAfter() {
		return doAfter;
	}

	public void setDoAfter(boolean doAfter) {
		this.doAfter = doAfter;
	}
	
	
}
